
var resMgrList = new Pearlsen.BaseEdit({
	gridId:'resMgrGrid',
	formId:'resMgrGrid',
	advSearchId:'advSearchWin',
	module:'resMgr',
	modulePath:'/pages/rms/resourcesMonitor/',
	moduleName:'resMgr',
	idProperty:'resMgr_NAME',
	nameProperty:'resMgr_DESCRIBE',
	dataSetHandler:'VAPPMgrDataSetHandler',
	queryHandler:'ResourcesMonitorQueryHandler',
	
	statusRender:function(value){
    var val = value;
    switch (value) {
        case "POWERED_ON":
            val = "<span style='color:green;'>正在运行</span>";
            break;
        case "POWERED_OFF":
            val = "<span style='color:red;'>已停止</span>";
            break;
    }
    return val;
},
	
loadVapp:function(thiz,records,opts){
    var r = records[0];
    if(r){
    	Ext.getCmp("vappGrid").getStore().loadData(r.get("vappsList"));
    }
},

loadVM:function(thiz,record,meta,index){		
	//获取多个vapplist
	Ext.getCmp("VMGrid").getStore().loadData(record.get("vmList"));
},


goToResReal:function(){
	var me = resMgrList;
	var record= Ext.getCmp("VMGrid").getSelectionModel().getLastSelected();
	if(record.length==0){
		Pearlsen.Utils.showErrorMsg('请选择一条记录');
		return;
	}
	var vmid =record.get("VM_Name")+" ("+record.get("VM_ID").split(":")[3]+")";
	var tabId = vmid;//resMgrList.createTabId(vmid);
	parent.MainTab.addTab(vmid+"_R","实时监控","/pages/rms/resourcesMonitor/ViewRealtimeInfo.jsp?vmname="+vmid);

	
},

goToResHis:function(){
	var me = resMgrList;
	var record= Ext.getCmp("VMGrid").getSelectionModel().getLastSelected();
	if(record.length==0){
		Pearlsen.Utils.showErrorMsg('请选择一条记录');
		return;
	}
	var vmid =record.get("VM_Name")+" ("+record.get("VM_ID").split(":")[3]+")";
	var tabId = vmid;//resMgrList.createTabId(vmid);
	parent.MainTab.addTab(tabId,"历史监控","/pages/rms/resourcesMonitor/ViewHistoryInfo.jsp?vmname="+vmid);
},

goToResRealAll:function(){
	var me = resMgrList;
	var record= Ext.getCmp("VMGrid").getSelectionModel().getLastSelected();
	if(record.length==0){
		Pearlsen.Utils.showErrorMsg('请选择一条记录');
		return;
	}
	var vmid =record.get("VM_Name")+" ("+record.get("VM_ID").split(":")[3]+")";
	var tabId = vmid;
	parent.MainTab.addTab(vmid+"_R","实时监控","/pages/rms/resourcesMonitor/ViewRealtimeInfoAll.jsp?vmname="+vmid);

	
},

goToResHisAll:function(){
	var me = resMgrList;
	var record= Ext.getCmp("VMGrid").getSelectionModel().getLastSelected();
	if(record.length==0){
		Pearlsen.Utils.showErrorMsg('请选择一条记录');
		return;
	}
	var vmid =record.get("VM_Name")+" ("+record.get("VM_ID").split(":")[3]+")";
	var tabId = vmid;//resMgrList.createTabId(vmid);
	parent.MainTab.addTab(tabId,"历史监控","/pages/rms/resourcesMonitor/ViewHistoryInfoAll.jsp?vmname="+vmid);

}

});